package io.renren.modules.substation.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.socket.SendMsgToClent;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.substation.entity.TBusiLinkageLogEntity;
import io.renren.modules.substation.service.TBusiLinkageLogService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 系统联动记录表
 *
 * @author yzx
 * @email sunlightcs@gmail.com
 * @date 2020-06-24 17:25:25
 */
@RestController
@RequestMapping("substation/tbusilinkagelog")
public class TBusiLinkageLogController {
    @Autowired
    private TBusiLinkageLogService tBusiLinkageLogService;

    /**
     * 列表
     */
    @RequestMapping("/list")
//    @RequiresPermissions("substation:tbusilinkagelog:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tBusiLinkageLogService.queryPage(params);

//        SendMsgToClent.sendJSONtoClent();

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{logId}")
    @RequiresPermissions("substation:tbusilinkagelog:info")
    public R info(@PathVariable("logId") Long logId){
		TBusiLinkageLogEntity tBusiLinkageLog = tBusiLinkageLogService.getById(logId);

        return R.ok().put("tBusiLinkageLog", tBusiLinkageLog);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("substation:tbusilinkagelog:save")
    public R save(@RequestBody TBusiLinkageLogEntity tBusiLinkageLog){
		tBusiLinkageLogService.save(tBusiLinkageLog);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("substation:tbusilinkagelog:update")
    public R update(@RequestBody TBusiLinkageLogEntity tBusiLinkageLog){
		tBusiLinkageLogService.updateById(tBusiLinkageLog);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("substation:tbusilinkagelog:delete")
    public R delete(@RequestBody Long[] logIds){
		tBusiLinkageLogService.removeByIds(Arrays.asList(logIds));

        return R.ok();
    }

}
